package com.uphone.kingmall.adapter;

import android.graphics.Color;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.china.zhuoyue.R;
import com.uphone.kingmall.bean.YongJinRankingBean;
import com.uphone.kingmall.utils.CommonUtil;
import com.uphone.kingmall.utils.GlideUtils;

/**
 * author : SuMeng
 * e-mail : 986335838@qq.com
 * time   : 2019/05/22
 * desc   : xxxx 描述
 */
public class YongJinRankingAdapter extends BaseQuickAdapter<YongJinRankingBean.MapBean.RecordResumeVoBean, BaseViewHolder> {
    public YongJinRankingAdapter() {
        super(R.layout.kingmall_item_yongjin_ranking);
    }

    @Override
    protected void convert(BaseViewHolder helper, YongJinRankingBean.MapBean.RecordResumeVoBean item) {
        if (helper.getLayoutPosition() == 0) {
            helper.setGone(R.id.tv_ranking, false)
                    .setGone(R.id.tv_mine_ranking, true);
        } else {
            helper.setGone(R.id.tv_ranking, true)
                    .setGone(R.id.tv_mine_ranking, false);
        }
        TextView tv_ranking = helper.getView(R.id.tv_ranking);
        if (helper.getLayoutPosition() == 1) {
            tv_ranking.setTextColor(Color.parseColor("#DCA706"));
        } else if (helper.getLayoutPosition() == 2) {
            tv_ranking.setTextColor(Color.parseColor("#FF6F29"));
        } else if (helper.getLayoutPosition() == 3) {
            tv_ranking.setTextColor(Color.parseColor("#E92727"));
        } else {
            tv_ranking.setTextColor(Color.parseColor("#CCCCCC"));
        }
        tv_ranking.setText(helper.getLayoutPosition() + ".");
        GlideUtils.getInstance().loadCircleImage(mContext, CommonUtil.getStr(item.getImage()), (ImageView) helper.getView(R.id.iv_head));

        helper.setText(R.id.tv_user_name, TextUtils.isEmpty(item.getUsername()) ? "" : item.getUsername())
                .setText(R.id.tv_mine_ranking, item.getRunm() == 0 ? "暂无排名" : "第" + item.getRunm() + "名")
                .setText(R.id.tv_user_money, item.getMoney() + "");
    }
}
